package cn.powerone.scm.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.powerone.common.annotation.Log;
import cn.powerone.common.core.controller.BaseController;
import cn.powerone.common.core.domain.AjaxResult;
import cn.powerone.common.enums.BusinessType;
import cn.powerone.scm.domain.ScmStatsYearly;
import cn.powerone.scm.service.IScmStatsYearlyService;
import cn.powerone.common.utils.poi.ExcelUtil;
import cn.powerone.common.core.page.TableDataInfo;

/**
 * 年度统计信息-总Controller
 * 
 * @author PowerOne
 * @date 2025-09-09
 */
@RestController
@RequestMapping("/scm/scmStatsYearly")
public class ScmStatsYearlyController extends BaseController
{
    @Autowired
    private IScmStatsYearlyService scmStatsYearlyService;

    /**
     * 查询年度统计信息-总列表
     */
    @PreAuthorize("@ss.hasPermi('scm:scmStatsYearly:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScmStatsYearly scmStatsYearly)
    {
        startPage();
        List<ScmStatsYearly> list = scmStatsYearlyService.selectScmStatsYearlyList(scmStatsYearly);
        return getDataTable(list);
    }

    /**
     * 导出年度统计信息-总列表
     */
    @PreAuthorize("@ss.hasPermi('scm:scmStatsYearly:export')")
    @Log(title = "年度统计信息-总", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScmStatsYearly scmStatsYearly)
    {
        List<ScmStatsYearly> list = scmStatsYearlyService.selectScmStatsYearlyList(scmStatsYearly);
        ExcelUtil<ScmStatsYearly> util = new ExcelUtil<ScmStatsYearly>(ScmStatsYearly.class);
        util.exportExcel(response, list, "年度统计信息-总数据");
    }

    /**
     * 获取年度统计信息-总详细信息
     */
    @PreAuthorize("@ss.hasPermi('scm:scmStatsYearly:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(scmStatsYearlyService.selectScmStatsYearlyById(id));
    }

    /**
     * 新增年度统计信息-总
     */
    @PreAuthorize("@ss.hasPermi('scm:scmStatsYearly:add')")
    @Log(title = "年度统计信息-总", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScmStatsYearly scmStatsYearly)
    {
        return toAjax(scmStatsYearlyService.insertScmStatsYearly(scmStatsYearly));
    }

    /**
     * 修改年度统计信息-总
     */
    @PreAuthorize("@ss.hasPermi('scm:scmStatsYearly:edit')")
    @Log(title = "年度统计信息-总", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScmStatsYearly scmStatsYearly)
    {
        return toAjax(scmStatsYearlyService.updateScmStatsYearly(scmStatsYearly));
    }

    /**
     * 删除年度统计信息-总
     */
    @PreAuthorize("@ss.hasPermi('scm:scmStatsYearly:remove')")
    @Log(title = "年度统计信息-总", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(scmStatsYearlyService.deleteScmStatsYearlyByIds(ids));
    }
}
